#!/usr/bin/env python
# *-* coding : utf-8 *-*
#
#       youtube_syncronizer
#       
#       Copyright 2009 Frederico Rodrigues Chevitarese <fchevitarese@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

from django.contrib import admin
from django_youtube_syncronizer.models import *

class local_model(admin.ModelAdmin):
    def del_item(self,object):
        opts = self.model._meta
        app_label = opts.app_label # Aqui eu pego o label da aplicacao
        class_name = opts.object_name.lower() # aqui pego o nome da classe
        return '<a href=/admin/%s/%s/%s/delete/>Deletar<a/>' %(app_label, class_name, object.id)

    del_item.allow_tags = True

class feed_admin(local_model):
    list_display = ('feed_user', 'del_item')
    search_fields = ['feed_user']

class video_admin(local_model):
    list_display = ('title', 'published', 'url', 'videoChannel', 'del_item')
    list_filter = ['videoChannel']
    search_fields = ['title', 'videoChannel']
    date_hierarcy = 'published'

admin.site.register(new_feed, feed_admin)
admin.site.register(video_data, video_admin)
